package com.bt.lms.ui.action.registration.stu;

import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.control.Alert;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

import java.io.File;

/**
 * 编辑学员报名信息 身份证编辑按钮事件
 */
public class PageEditIDEditBtnAction implements EventHandler {

    @Override

    public void handle(Event event) {
        //文件选择器
        FileChooser fileChooser = new FileChooser();
        File file = fileChooser.showOpenDialog(new Stage());
        String fileName = null;
        try {
            fileName = file.getName();
        } catch (Exception e) {
            return;
        }

        if (!fileName.endsWith(".jpg") && !fileName.endsWith(".jpeg") && !fileName.endsWith(".gif") && !fileName.endsWith(".pdf") && !fileName.endsWith(".png")){
            Alert alert = new Alert(Alert.AlertType.WARNING);
            alert.setContentText("文件格式不正确");
            alert.showAndWait();

        }
        int fileLen = fileName.length();
        if (fileLen>50){
            Alert alert = new Alert(Alert.AlertType.WARNING);
            alert.setContentText("文件大小不能超过50MB");
            alert.showAndWait();

        }



    }
}
